/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2023-04-17
 * Time: 19:33
 */

public class Yest {
    public static int[] selectionSort(int []arr) {
        if (arr == null || arr.length < 2) {
            return null;
        }
            for(int i=0;i<arr.length-1;i++){
                int minindex=i;
                for(int j=i+1;j<arr.length;j++){
                    minindex=arr[j]<minindex?j:minindex;
                }
                        swap(arr,i,minindex);
            }
        return arr;
    }
    public static  void swap(int []arr,int i,int j){
        int tmp=arr[i];
        arr[i]=arr[j];
        arr[j]=tmp;

    }


    public static void main(String[] args) {
       int [] arr=new int[]{1,5,8,9,12,3,89};
       System.out.println(arr);

    }
}
